﻿using RuoVea.ExSugar.Attributes;
using System.ComponentModel.DataAnnotations;

namespace RuoVea.OmiApi.SystemApp.Entitys;

/// <summary>
/// 菜单表
/// </summary>
[SugarTable(nameof(SysMenu), "菜单表")]
[Description("菜单表")]
[Tenant("0")]
[SugarIndex("index_{table}_T", nameof(Name), OrderByType.Asc)]
[SugarIndex("index_{table}_T2", nameof(Type), OrderByType.Asc)]
public class SysMenu : EntityBase, ITenantEntity
{
    /// <summary>
    /// 租户Id
    /// </summary>
    [ConfigSugarTenantColumn("TenantId", "租户Id", false, true, false)]
    public long? TenantId { get; set; }
    /// <summary>
    /// 父Id
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Pid), columnDescription:"父Id")]
    public long Pid { get; set; }

    /// <summary>
    /// 菜单类型（1目录 2菜单 3按钮）
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Type), columnDescription:"菜单类型")]
    public MenuType Type { get; set; }

    /// <summary>
    /// 路由名称
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Name), columnDescription:"路由名称", Length = 64, IsNullable = true)]
    [MaxLength(64)]
    public string Name { get; set; }

    /// <summary>
    /// 路由地址
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Path), columnDescription:"路由地址", Length = 128, IsNullable = true)]
    [MaxLength(128)]
    public string Path { get; set; }

    /// <summary>
    /// 组件路径
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Component), columnDescription:"组件路径", Length = 128, IsNullable = true)]
    [MaxLength(128)]
    public string Component { get; set; }

    /// <summary>
    /// 重定向
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Redirect), columnDescription:"重定向", Length = 128, IsNullable = true)]
    [MaxLength(128)]
    public string Redirect { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Permission), columnDescription:"权限标识", Length = 128, IsNullable = true)]
    [MaxLength(128)]
    public string Permission { get; set; }

    /// <summary>
    /// 菜单名称
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Title), columnDescription:"菜单名称", Length = 64, IsNullable = true)]
    [Required, MaxLength(64)]
    public virtual string Title { get; set; }

    /// <summary>
    /// 图标
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Icon), columnDescription:"图标", Length = 128, IsNullable = true)]
    [MaxLength(128)]
    public string Icon { get; set; }

    /// <summary>
    /// 是否内嵌
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(IsIframe), columnDescription:"是否内嵌", IsNullable = true)]
    public bool IsIframe { get; set; }

    /// <summary>
    /// 外链链接
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(OutLink), columnDescription:"外链链接", Length = 256, IsNullable = true)]
    [MaxLength(256)]
    public string OutLink { get; set; }

    /// <summary>
    /// 是否隐藏
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(IsHide), columnDescription:"是否隐藏", IsNullable = true)]
    public bool IsHide { get; set; }

    /// <summary>
    /// 是否缓存
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(IsKeepAlive), columnDescription:"是否缓存", IsNullable = true)]
    public bool IsKeepAlive { get; set; } = true;

    /// <summary>
    /// 是否固定
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(IsAffix), columnDescription:"是否固定", IsNullable = true)]
    public bool IsAffix { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Sort), columnDescription:"排序", IsNullable = true)]
    public int Sort { get; set; } = 100;

    /// <summary>
    /// 状态
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(IsDisable), columnDescription:"状态", IsNullable = true)]
    public YesOrNot IsDisable { get; set; } = YesOrNot.N;

    /// <summary>
    /// 备注
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Remark), columnDescription:"备注", Length = 256, IsNullable = true)]
    [MaxLength(256)]
    public string Remark { get; set; }

    /// <summary>
    /// 菜单子项
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public List<SysMenu> Children { get; set; } = new List<SysMenu>();
}
